# -*- coding: utf-8 -*-
import sys
import os

# 添加项目根目录到系统路径
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(current_dir)

from resource.question_classifier import QuestionClassifier
from resource.question_parser import QuestionPaser
from resource.answer_search import AnswerSearcher

class ChatBotGraph:
    def __init__(self):
        self.classifier = QuestionClassifier()
        self.parser = QuestionPaser()
        self.searcher = AnswerSearcher()

    def chat_main(self, question):
        answer = "抱歉，我暂时无法理解您的问题。"
        res_classify = self.classifier.classify(question)
        if not res_classify:
            return answer
        res_sql = self.parser.parser_main(res_classify)
        final_answers = self.searcher.search_main(res_sql)
        if not final_answers:
            return answer
        else:
            return '\n'.join(final_answers) 